<?php
class AdminSaveEditAction extends AdminAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'json';
	}
	
	protected function afterConstruct()
	{
		$this->parseDtds('admin','edit');
	}
	
	public function execute()
	{
		$oldPassword	= $this->context->post('oldpassword');
		$password		= $this->context->post('password');
		$adminService	= new AdminService();
		$user			= $adminService->get($this->context->adminId);
		if($user && md5(md5($oldPassword).$user['secques'])==$user['password'])
		{
			$adminService->updateUserPassword($user['id'], $password, $user['secques']);
			$this->code	= 200;
			$this->data['forward'] = C('LtUrl')->generate('Default', 'Login');
		}
		else
		{
			$this->code	= 500;
		}
	}
}
